package com.store.framework.rest;
import java.util.List;
import java.util.UUID;

import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.store.framework.entry.AppImagesTbl;
import com.store.framework.logic.IAppImagesLogic;
import com.store.framework.logic.imp.AppImagesLogic;
public class AImagesService {
	IAppImagesLogic iappimgageslogic = new AppImagesLogic();
	// @GET
	// @Produces(MediaType.TEXT_HTML)
	// @Path("addUser")
	 @POST
	 @Path("addImg")
	 @Produces("application/json; charset=UTF-8")
	
	public String addImg(String input) {
		System.out.println(input);
		JSONObject jo = JSONObject.fromObject(input);
		@SuppressWarnings("static-access")
		AppImagesTbl at = (AppImagesTbl) jo.toBean(jo, AppImagesTbl.class);
		at.setId(UUID.randomUUID().toString());

		iappimgageslogic.add(at);

		return "{\"result\":1}";
	}
	@POST
	@Path("selectAppImg")
	@Produces("application/json; charset=UTF-8")
	public String selectAppImg() {
		@SuppressWarnings("rawtypes")
		List list = iappimgageslogic.select();
		JSONArray ja = JSONArray.fromObject(list);
		System.out.println(ja);

		return ja.toString();
	}

	public static void main(String[] args) {

		new AImagesService().selectAppImg();
	}
}
